package h.a.a.j;

import h.a.a.d;
import h.a.a.f;
import h.a.a.i.b;
import h.a.a.i.c;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;

/* compiled from: DaoConfig */
public final class a implements Cloneable {
    public final h.a.a.h.a a;
    public final String b;
    public final f[] c;
    public final String[] d;
    public final String[] e;
    public final String[] f;
    public final f g;
    public final boolean h;
    public final e i;
    public h.a.a.i.a<?, ?> j;

    public a(h.a.a.h.a aVar, Class<? extends h.a.a.a<?, ?>> cls) {
        this.a = aVar;
        try {
            f fVar = null;
            this.b = (String) cls.getField("TABLENAME").get(null);
            f[] b = b(cls);
            this.c = b;
            this.d = new String[b.length];
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            boolean z = false;
            f fVar2 = null;
            for (int i = 0; i < b.length; i++) {
                f fVar3 = b[i];
                String str = fVar3.e;
                this.d[i] = str;
                if (fVar3.d) {
                    arrayList.add(str);
                    fVar2 = fVar3;
                } else {
                    arrayList2.add(str);
                }
            }
            this.f = (String[]) arrayList2.toArray(new String[arrayList2.size()]);
            String[] strArr = (String[]) arrayList.toArray(new String[arrayList.size()]);
            this.e = strArr;
            if (strArr.length == 1) {
                fVar = fVar2;
            }
            this.g = fVar;
            this.i = new e(aVar, this.b, this.d, strArr);
            if (fVar != null) {
                Class cls2 = fVar.b;
                if (cls2.equals(Long.TYPE) || cls2.equals(Long.class) || cls2.equals(Integer.TYPE) || cls2.equals(Integer.class) || cls2.equals(Short.TYPE) || cls2.equals(Short.class) || cls2.equals(Byte.TYPE) || cls2.equals(Byte.class)) {
                    z = true;
                }
                this.h = z;
                return;
            }
            this.h = false;
        } catch (Exception e) {
            throw new d("Could not init DAOConfig", e);
        }
    }

    public static f[] b(Class<? extends h.a.a.a<?, ?>> cls) throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
        int i;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(cls.getName());
        stringBuilder.append("$Properties");
        Field[] declaredFields = Class.forName(stringBuilder.toString()).getDeclaredFields();
        ArrayList arrayList = new ArrayList();
        for (Field field : declaredFields) {
            if ((field.getModifiers() & 9) == 9) {
                Object obj = field.get(null);
                if (obj instanceof f) {
                    arrayList.add((f) obj);
                }
            }
        }
        f[] fVarArr = new f[arrayList.size()];
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            f fVar = (f) it.next();
            i = fVar.a;
            if (fVarArr[i] == null) {
                fVarArr[i] = fVar;
            } else {
                throw new d("Duplicate property ordinals");
            }
        }
        return fVarArr;
    }

    public void a(h.a.a.i.d dVar) {
        if (dVar == h.a.a.i.d.None) {
            this.j = null;
        } else if (dVar != h.a.a.i.d.Session) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Unsupported type: ");
            stringBuilder.append(dVar);
            throw new IllegalArgumentException(stringBuilder.toString());
        } else if (this.h) {
            this.j = new b();
        } else {
            this.j = new c();
        }
    }

    public Object clone() throws CloneNotSupportedException {
        return new a(this);
    }

    public a(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = aVar.c;
        this.d = aVar.d;
        this.e = aVar.e;
        this.f = aVar.f;
        this.g = aVar.g;
        this.i = aVar.i;
        this.h = aVar.h;
    }
}
